package inject;

import java.time.LocalDateTime;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;


@Component
public class Zoo{
	
	@Value("${zoo.name}")
	private String zoo_name;
	
	@Autowired
	private Cat cat;
	
	@Autowired(required=false)
	// @Resource
	private Dog dog;
	
	@Autowired
	private Tiger tiger;
	
	
	@Autowired
	private Cat cat1;
	
	@Resource
	private Cat cat2;
	
	
	
	@Resource(name="cat")
	// @Autowired @Qualifier("cat")
	private Pet cat3;
	
	@Autowired(required=false) @Qualifier("catNotExist")
	// @Autowired  @Qualifier("catNotExist")
	private Pet cat4;
	
	@Autowired @Qualifier("tiger")
	private Pet petTiger;
	
	
	public Zoo(){
		System.out.println("Zoo() run,"+LocalDateTime.now());
	}
	
	
		
	public void setCat1(Cat cat1) {
		this.cat1 = cat1;
	}



	public String info(){
		StringBuilder sb = new StringBuilder();
		
		sb.append("cat="+cat);
		sb.append(",dog="+dog);
		sb.append(",tiger="+tiger);
		
		sb.append(",cat1="+cat1);
		sb.append(",cat2="+cat2);
		sb.append(",cat3="+cat3);
		sb.append(",cat4="+cat4);
		// petTiger
		sb.append(",petTiger="+petTiger);

		sb.append(",zoo_name="+zoo_name);



		return sb.toString();
	}
	
}
